array('group'), 'description' => t('Associate theme to a group.'), 'field' => array( 'field_name' => OG_THEME_FIELD, 'no_ui' => TRUE, 'type' => 'list_text', 'cardinality' => 1, 'settings' => array('allowed_values' => array(), 'allowed_values_function' => 'og_theme_field_allowed_values'), ), 'instance' => array( 'label' => t('Groups theme'), 'widget_type' => 'options_select', 'required' => TRUE, // Use default theme as default value. 'default_value' => array(0 => array('value' => '__default')), 'view modes' => array( 'full' => array( 'label' => 'above', 'type' => 'list_default', ), 'teaser' => array( 'label' => 'above', 'type' => 'list_default', ), ), ), ); return $items; $items[OG_LOGO_FIELD] = array( 'type' => array('group'), 'description' => t('Associate logo to a group.'), 'field' => array( 'field_name' => OG_LOGO_FIELD, 'no_ui' => TRUE, 'type' => 'image', 'cardinality' => 1, 'settings' => array('allowed_values' => array(), 'allowed_values_function' => 'og_logo_field_allowed_values'), ), 'instance' => array( 'label' => t('Groups logo'), 'widget_type' => 'image', 'required' => TRUE, // Use default logo as default value. 'default_value' => array(0 => array('value' => '__default')), 'view modes' => array( 'full' => array( 'label' => 'above', 'type' => 'image', ), 'teaser' => array( 'label' => 'above', 'type' => 'image', ), ), ), ); return $items; $items[OG_SLOGAN_FIELD] = array( 'type' => array('group'), 'description' => t('Associate slogan to a group.'), 'field' => array( 'field_name' => OG_SLOGAN_FIELD, 'no_ui' => TRUE, 'type' => 'text', 'cardinality' => 1, 'settings' => array('allowed_values' => array(), 'allowed_values_function' => 'og_slogan_field_allowed_values'), ), 'instance' => array( 'label' => t('Groups slogan'), 'widget_type' => 'text', 'required' => TRUE, // Use default slogan as default value. 'default_value' => array(0 => array('value' => '__default')), 'view modes' => array( 'full' => array( 'label' => 'above', 'type' => 'text', ), 'teaser' => array( 'label' => 'above', 'type' => 'text', ), ), ), ); return $items; $items[OG_EMAIL_FIELD] = array( 'type' => array('group'), 'description' => t('Associate email to a group.'), 'field' => array( 'field_name' => OG_EMAIL_FIELD, 'no_ui' => TRUE, 'type' => 'text', 'cardinality' => 1, 'settings' => array('allowed_values' => array(), 'allowed_values_function' => 'og_email_field_allowed_values'), ), 'instance' => array( 'label' => t('Groups email'), 'widget_type' => 'text', 'required' => TRUE, // Use default email as default value. 'default_value' => array(0 => array('value' => '__default')), 'view modes' => array( 'full' => array( 'label' => 'above', 'type' => 'text', ), 'teaser' => array( 'label' => 'above', 'type' => 'text', ), ), ), ); return $items; } /** * Implements hook_custom_theme(). * * Change the theme, based on a group context. */ function og_theme_custom_theme() { if ($group = og_context()) { // Load the entity. $entity = $group->getEntity(); // Check if a theme field exists, and it isn't defined as "default" // (i.e. use the default site theme). if (!empty($entity->{OG_THEME_FIELD}[LANGUAGE_NONE][0]['value']) && $entity->{OG_THEME_FIELD}[LANGUAGE_NONE][0]['value'] != '__default') { return $entity->{OG_THEME_FIELD}[LANGUAGE_NONE][0]['value']; } } } /** * Return all enabled themes. */ function og_theme_field_allowed_values() { $return = array('__default' => t('Use site-wide theme definition')); module_load_include('inc', 'system', 'system.admin'); $themes = list_themes(); uasort($themes, 'system_sort_modules_by_info_name'); foreach ($themes as $key => $value) { if ($value->status) { $return[$key] = check_plain($value->info['name']); } } return $return; }